package gew.services;

import gew.utils.SqlUtils;
import java.util.Locale;

public class LocaleService {

    public static final String RU = "ru";
    public static final String EN = "en";
    public static final String RU_RU = "ru_RU";
    public static final String EN_US = "en_US";
    private static final Locale localeRU = new Locale("ru", "RU");
    private static final Locale localeEN = new Locale("en", "US");
    
    public static Locale getLocale(String localeCode) {
        switch (localeCode) {
            case RU:
            case RU_RU:
                return localeRU;
            case EN:
            case EN_US:
                return localeEN;
            default:
                return localeEN;
        }
    }
    
    public static String getLocaleCode(String localeCode) {
        switch (localeCode) {
            case RU:
            case RU_RU:
                return RU;
            case EN:
            case EN_US:
                return EN;
            default:
                return EN;
        }
    }
    
    public static String getLocaleCode(Locale locale) {
        if (locale == localeRU) {
            return RU;
        } else {
            return EN;
        }
    }
    
    public static Locale getLocaleRU(){
        return localeRU;
    }
    
    public static Locale getLocaleEN(){
        return localeEN;
    }
    
    public static char getDecimalSeparator(Locale locale){
        if (locale == localeRU) {
            return SqlUtils.CHAR_COMMA;
        } else {
            return SqlUtils.CHAR_POINT;
        }
    }
    
    public static char getGroupingSeparator(Locale locale){
        return SqlUtils.CHAR_SPACE;
    }
    
    public static String getSecondLocale(String localeCode){
        switch (localeCode) {
            case RU:
            case RU_RU:
                return EN;
            case EN:
            case EN_US:
                return RU;
            default:
                return RU;
        }
    }
}
